package model;
import java.util.Objects;
public class Goods {
    /**
     * 商品
     */
    private String goodsNo;  //商品编号
    private String goodsName;   //商品名称
    private double cost;   //成本
    private double price;    //价格
    private int count;    //数量
    private Category category;    //商品分类

    public Goods(String goodsNo, String goodsName, double cost, double price, int count,Category category) {
        this.goodsNo = goodsNo;
        this.goodsName = goodsName;
        this.cost = cost;
        this.price = price;
        this.count = count;
        this.category = category;
    }
    public Goods(String no){
        this.goodsNo = no;
    }
    public Goods(){}

    public String getGoodsNo(){
        return goodsNo;
    }
    public void setGoodsNo(String no) {
        this.goodsNo = no;
    }

    public String getGoodsName() {
        return goodsName;
    }

    public void setGoodsName(String goodsName) {
        this.goodsName = goodsName;
    }

    public double getCost() {
        return cost;
    }

    public void setCost(double cost) {
        this.cost = cost;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }

    public Category getCategory() {
        return category;
    }

    public void setCategory(Category category) {
        this.category = category;
    }

    @Override
    public String toString() {
        return  "【商品】" +
                "商品编号" + goodsNo +
                ", 商品名称" + goodsName +
                ", 进货价" + cost +
                ", 零售价" + price +
                ", 库存" + count +
                ", 分类" + (category == null ? "无" : category.getName());
    }

    public String show(){
        return "【商品】" +
                "商品编号：" + goodsNo +
                ", 商品名称：" + goodsName +
                ", 售价：" + price +
                ", 库存：" + count +
                ", 分类：" + (category == null? "无" : category.getName());
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        Goods goods = (Goods) o;
        return goodsNo.equals(goods.goodsNo);
    }

    @Override
    public int hashCode() {
        return Objects.hash(goodsNo);
    }
}
